import java.util.*;

public class project {
    public int isPrefixOfWord(String sentence, String searchWord) {
        String[] str=sentence.split(" ");
        int index=-1;
        for(int i=0;i<str.length;i++){
            String s=str[i];
            int len=s.length();
            if(len>=searchWord.length()&&s.substring(0,searchWord.length()).equals(searchWord)){
                index=i+1;
                break;
            }
        }
        return index;
    }

















    public int countWords(String[] words1, String[] words2) {
        Map<String,Integer> map1=new HashMap<>();
        Map<String,Integer> map2=new HashMap<>();
        for(String str : words1){
            map1.put(str,map1.getOrDefault(str,0)+1);
        }
        for(String str : words2){
            map2.put(str,map2.getOrDefault(str,0)+1);
        }
        int sum=0;
        for(String str : map1.keySet()){
            if(map1.get(str)==1&&map2.get(str)!=null&&map2.get(str)==1){
                sum++;
            }
        }
        return sum;
    }












    public List<Integer> targetIndices(int[] nums, int target) {
        List<Integer> list=new ArrayList<>();
        Arrays.sort(nums);
        for(int i=0;i<nums.length;i++){
            if(nums[i]==target){
                list.add(i);
            }
        }
        return list;
    }














    public int countPoints(String rings) {
        Map<Character,Set<Character>> map=new HashMap();
        int n=rings.length()/2;
        for(int i=0;i<rings.length();i+=2){
            char ch=rings.charAt(i);
            char index=rings.charAt(i+1);
            Set<Character> set=map.getOrDefault(index, new HashSet<>());
            set.add(ch);
            map.put(index,set);
        }
        int sum=0;
        for(Map.Entry<Character,Set<Character>> entry : map.entrySet()){
            if(entry.getValue().size()==3){
                sum++;
            }
        }
        return sum;
    }











    public int[] findEvenNumbers(int[] digits) {
        Set<Integer> set=new HashSet<>();
        int len=digits.length;
        for(int i=0;i<len;i++){
            for(int j=0;j<len;j++){
                for(int k=0;k<len;k++){
                    if(i!=j&&j!=k&&i!=k){
                        int tmp=((((digits[i]*10)+digits[j])*10)+digits[k]);
                        if(tmp>99&&tmp%2==0){
                            set.add(tmp);
                        }
                    }
                }
            }
        }
        int index=0;
        int[] arr=new int[set.size()];
        for(Integer tmp : set){
            arr[index++]=tmp;
        }
        Arrays.sort(arr);
        return arr;
    }











    public int numWaterBottles(int numBottles, int numExchange) {
        int count=numBottles;
        if(numBottles<numExchange){
            return count;
        }
        while(numBottles>=numExchange){
            count+=numBottles/numExchange;
            numBottles=(numBottles/numExchange)+(numBottles%numExchange);
        }
        return count;
    }
}
